package com.fraud.job;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.log4j.Logger;

import com.fraud.Util;
import com.fraud.bean.FileProcessBean;
import com.fraud.dao.KullaniciDao;

@Singleton
@Startup
public class FileProcessorJob {

	private final Logger logger = Logger.getLogger(FileProcessorJob.class);

	@PersistenceContext
	EntityManager entityManager;

	@EJB
	FileProcessBean fileProcessorBean;
	
	@EJB
	KullaniciDao userDao;

	
	//TODO buradaki ayar confiugurasyona tasinmasi lazım
	@Schedule(hour = "4" , minute = "1",second="1", persistent = false)
	public void run() throws Exception {

		logger.info("This job starting.");
		
		
		fileProcessorBean.processFiles(userDao.getSystemKullanici());

		logger.info("This job finished.");
	}
}
